<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>login</title>
    <script src="../utils/jquery3-7-1.js"></script>
  </head>
  <body>
    <div class="title">
      <div>
        <label for="username"
          >用户名:<input
            type="text"
            name="username"
            value="admin"
            id="username"
        /></label>
      </div>
      <div>
        <label for="password"
          >密码:<input
            type="password"
            name="password"
            value="123"
            id="password"
        /></label>
      </div>
      <button id="submit">提交</button>
      <button id="getuser">获取用户信息</button>
    </div>
    <script>
      $(function () {
        var username = $("#username").val();
        var password = $("#password").val();
        $("#submit").click(() => {
          $.ajax({
            type: "POST",
            url: "http://127.0.0.1/login",
            data: { username: username, password: password },
            success: (res) => {
              console.log(res);
              // window.location.href = "./manage.html";
              //  五种跳转方式，按需选择即可；
              // 【1】第一种跳转方式：window.location.href="跳转的htm页面";
              // 【2】第二种跳转方式：window.history.back(-1);
              // 【3】第三种跳转方式：window.navigate("跳转的htm页面");
              // 【4】第四种跳转方式：self.location="跳转的htm页面";
              // 【5】第五种跳转方式：top.location="跳转的htm页面"。
            },
          });
        });

        $("#getuser").click(() => {
          $.ajax({
            type: "POST",
            url: "http://127.0.0.1/getuser",
            success: (res) => {
              console.log(res);
            },
          });
        });
      });
    </script>
  </body>
</html>
